pub trait Summary{
    fn summarize(&self) -> String;
}
pub struct NewArticle{
    pub headline: String,
    pub location: String,
    pub author: String,
    pub content: String,
}
impl Summary for NewArticle{
    fn summarize(&self) -> String{
        format!("{}, by {} ({})",self.headline,self.author,self.location)
    }
}
pub struct Tweet{
    pub username: String,
    pub content: String,
    pub reply: bool,
    pub retweet:bool,
}
impl Summary for Tweet{
    fn summarize(&self)->String{
        format!("{}: {}",self.username,self.content)
    }
}
// trait作为参数
pub fn notify(item: &impl Summary){
    println!("Breaking news! {}", item.summarize());
}

fn returns_summarizable()-> impl Summary{
    Tweet{
        username: String::from("horse_ebooks"),
        content: String::from(
            "of course, as you probably already know, people",
        ),
        reply: false,
        retweet: false,
    }
}